home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / radiotv.exe / RADIO.CPP < prev    next >
C/C++ Source or Header  |  1992-07-30  |  6KB  |  218 lines

  1. //========================================================================
  2. //  The following example routines have been provided by the Technical
  3. //  Support staff at Borland International.  They are provided as a
  4. //  courtesy and not as part of a Borland product, and as such, are
  5. //  provided without the assurance of technical support or any specific
  6. //  guarantees.
  7. //========================================================================
  8.  
  9. //---------------------------------------------------------------------------
  10. //   RadioButtons:
  11. //       This is an example of breaking apart the TSItems into several
  12. //       sub menus.  This will eliminate the compiler message "out of
  13. //       memory."
  14. //--------------------------------------------------------------------------
  15.  
  16. #define Uses_MsgBox
  17. #define Uses_TApplication
  18. #define Uses_TEventQueue
  19. #define Uses_TEvent
  20. #define Uses_TKeys
  21. #define Uses_TRect
  22. #define Uses_TMenuBar
  23. #define Uses_TSubMenu
  24. #define Uses_TMenuItem
  25. #define Uses_TStatusLine
  26. #define Uses_TStatusItem
  27. #define Uses_TStatusDef
  28. #define Uses_TDeskTop
  29. #define Uses_TView
  30. #define Uses_TWindow
  31. #define Uses_TMenu
  32. #define Uses_TDialog
  33. #define Uses_TStaticText
  34. #define Uses_TButton
  35. #define Uses_TFileDialog
  36. #define Uses_TFileList
  37. #define Uses_TSItem
  38. #define Uses_TRadioButtons
  39.  
  40. #include <stdlib.h>
  41. #include <tv.h>
  42.  
  43. const int cmRadioDialog = 100;
  44.  
  45. class TMyApp : public TApplication
  46. {
  47.  
  48. public:
  49.     TMyApp();
  50.   static TMenuBar *initMenuBar( TRect );
  51.     static TStatusLine *initStatusLine( TRect );
  52.     void handleEvent(TEvent& event);
  53.   void RadioDialog(void);
  54.  
  55. };
  56.  
  57.  
  58. TMyApp::TMyApp() :
  59.     TProgInit( &initStatusLine,
  60.            &initMenuBar,
  61.            &initDeskTop
  62.          )
  63. {
  64. }
  65.  
  66.  
  67. //--------------------------------------------------------------------------
  68. //       Breaking up the Radio Buttons into several discrete parts will
  69. //       allow the use of more TSItems.
  70. //--------------------------------------------------------------------------
  71. void TMyApp::RadioDialog(void)
  72. {
  73.     TDialog *pd = new TDialog( TRect( 2,1,78,22), " Radio Buttons ");
  74.     if( validView( pd ) )
  75.     {
  76.  
  77.      TSItem *J1 = new TSItem("Nietsche",
  78.                   new TSItem("Kant",
  79.                   new TSItem("Daly",
  80.                   new TSItem("Socrates",
  81.                   new TSItem("Descartes",
  82.                   new TSItem("Hui",
  83.                   new TSItem("GLarkin",
  84.                   new TSItem("Plato",
  85.                   new TSItem("Babet",
  86.                   new TSItem("Farrell",
  87.                   new TSItem("Thoreau",
  88.                   new TSItem("Krull",
  89.                   new TSItem("Pippon",
  90.                   new TSItem("Bird",
  91.                   new TSItem("Jordan", 0 )))))))))))))));
  92.  
  93.                                         
  94.      TSItem *J2 = new TSItem("Nietsche2",
  95.                   new TSItem("Kant2",
  96.                   new TSItem("Daly2",
  97.                   new TSItem("Socrates2",
  98.                   new TSItem("Descartes2",
  99.                   new TSItem("Hui2",
  100.                   new TSItem("GLarkin2",
  101.                   new TSItem("Plato2",
  102.                   new TSItem("Babet2",
  103.                   new TSItem("Farrell2",
  104.                   new TSItem("Thoreau2",
  105.                   new TSItem("Krull2",
  106.                   new TSItem("Pippon2",
  107.                   new TSItem("Bird2",
  108.                   new TSItem("Jordan2", J1 )))))))))))))));
  109.  
  110.  
  111.      TSItem *J3 = new TSItem("Nietsche3",
  112.                   new TSItem("Kant3",
  113.                   new TSItem("Daly3",
  114.                   new TSItem("Socrates3",
  115.                   new TSItem("Descartes3",
  116.                   new TSItem("Hui3",
  117.                   new TSItem("GLarkin3",
  118.                   new TSItem("Plato3",
  119.                   new TSItem("Babet3",
  120.                   new TSItem("Farrell3",
  121.                   new TSItem("Thoreau3",
  122.                   new TSItem("Krull3",
  123.                   new TSItem("Pippon3",
  124.                   new TSItem("Bird3",
  125.                   new TSItem("Jordan3", J2 )))))))))))))));
  126.  
  127.  
  128.      TSItem *J4 = new TSItem("Nietsche4",
  129.                   new TSItem("Kant4",
  130.                   new TSItem("Daly4",
  131.                   new TSItem("Socrates4",
  132.                   new TSItem("Descartes4",
  133.                   new TSItem("Hui4",
  134.                   new TSItem("GLarkin4",
  135.                   new TSItem("Plato4",
  136.                   new TSItem("Babet4",
  137.                   new TSItem("Farrell4",
  138.                   new TSItem("Thoreau4",
  139.                   new TSItem("Krull4",
  140.                   new TSItem("Pippon4",
  141.                   new TSItem("Bird4",
  142.                   new TSItem("Jordan4", J3 )))))))))))))));
  143.  
  144.  
  145.  
  146.       TView *RadioButtons = new TRadioButtons( TRect(2,1,73,16), J4 );
  147.  
  148.       pd->insert( RadioButtons );
  149.  
  150.       deskTop->execView( pd );
  151.  
  152.     }
  153.  
  154.     destroy(pd);
  155.  
  156. }
  157.  
  158.  
  159. void TMyApp::handleEvent(TEvent& event)
  160. {
  161.    TApplication::handleEvent( event );
  162.  
  163.    if( event.what == evCommand )
  164.    {
  165.       switch( event.message.command)
  166.       {
  167.         case cmRadioDialog:
  168.            RadioDialog();
  169.            break;
  170.  
  171.         default:
  172.            break;
  173.       }
  174.       clearEvent( event );
  175.    }
  176. }
  177.  
  178.  
  179. TStatusLine *TMyApp::initStatusLine(TRect r)
  180. {
  181.    r.a.y = r.b.y - 1;
  182.  
  183.    return new TStatusLine( r,
  184.        *new TStatusDef( 0, 0xFFFF) +
  185.        *new TStatusItem( "~Alt-X~ Exit", kbAltX, cmQuit) +
  186.        *new TStatusItem( "~Alt-R~ Radio Buttons", kbAltR, cmRadioDialog)
  187.        );
  188.  
  189. }
  190.  
  191.  
  192. TMenuBar *TMyApp::initMenuBar( TRect r )
  193.     r.b.y = r.a.y + 1;
  194.     TMenuBar *t;
  195.  
  196.    TMenuItem *two =
  197.       new TMenuItem("~E~xit", cmQuit, kbAltX);
  198.  
  199.    TMenuItem *one =
  200.       new TMenuItem("~\xF0~", kbAltSpace,
  201.         new TMenu( *new TMenuItem("~R~adio Buttons", cmRadioDialog, kbAltR)),
  202.           hcNoContext, two);
  203.  
  204.     return ( new TMenuBar( r, new TMenu( *one ) )  );
  205.  
  206.  
  207. }
  208.  
  209.  
  210. int main()
  211. {
  212.  
  213.   TMyApp myApp;
  214.     myApp.run();
  215.     return 0;
  216. }
  217.